package main.java.com.extract;

/**
 * @description: java类作用描述
 * @author: cong zhi
 * @createDate: 2022/6/16 7:56
 * @updateUser: cong zhi
 * @updateDate: 2022/6/16 7:56
 * @updateRemark: 修改内容
 * @version: v1.0
 */
public class Movie {

    public static final int CHILDRENS = 2;
    public static final int REGULAR = 0;
    public static final int NEW_RELEASE = 1;

    private String title;
    private int priceCode;

    public Movie(String title, int priceCode) {
        this.title = title;
        this.priceCode = priceCode;
    }

    public String getTitle() {
        return title;
    }

    public int getPriceCode() {
        return priceCode;
    }

    /**
     * 影片租赁金额的计算
     *
     * @param days 租赁时间
     * @return
     */
    public double getAmount(int days) {

        double amount = 0;
        switch (getPriceCode()) {
            case REGULAR:
                amount += 2;
                if (days > 2) {
                    amount += (days - 2) * 1.5;
                }
                break;
            case NEW_RELEASE:
                amount += days * 3;
                break;
            case main.java.com.example.Movie.CHILDRENS:
                amount += 1.5;
                if (days > 3) {
                    amount += (days - 3) * 1.5;
                }
                break;
            default:
                throw new IllegalArgumentException("非法参数");
        }
        return amount;
    }

    public int getFrequentRetenterPoints(int days) {
        if (getPriceCode() == Movie.NEW_RELEASE && days > 1) {
            return 1;
        } else {
            return 0;
        }
    }
}
